//
//  Session.m
//  Conference Track Management
//
//  Created by Jiang on 2018/10/22.
//  Copyright © 2018 jiang. All rights reserved.
//

#import "Session.h"
#import "time.h"

@implementation Session
- (instancetype)initWithStartTime:(int)startTime endTime:(SessionEndTime *)endTime{
    self = [super init];
    self.startTime = startTime;
    self.endTime = endTime;
    self.minDuration = (endTime.earlistHour - startTime) * 60;
    self.maxDuration = (endTime.latestHour - startTime) * 60;
    NSAssert(self.minDuration > 0,@"");
    NSAssert(self.maxDuration > 0,@"");
    return self;
}
- (void)makeTrackWithTalks:(NSArray<id <Talk>> *)talks container:(NSMutableString *)container{
    int interval = 0;
    for (id <Talk>aTalk in talks) {
        NSString *timeStamp = [self.formatter timeStampForStartHour:self.startTime interval:interval];
        [container appendFormat:@"%@ %@\n", timeStamp,aTalk.content];
        interval += aTalk.duration * 60;
    }
    NSString *timeStamp = [self.formatter timeStampForStartHour:self.startTime interval:interval];
    [container appendFormat:@"%@ %@\n", timeStamp,self.finalDo];
}
@end

